VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MsComCtl.ocx"
Object = "{B3FB64BF-91F9-11D7-A482-0008A14158BC}#2.22#0"; "ITGControls.ocx"
Begin VB.Form frmToolSmartList 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Inquiries"
   ClientHeight    =   7410
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   12540
   Icon            =   "frmToolSmartList.frx":0000
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   7410
   ScaleWidth      =   12540
   Begin MSComctlLib.ImageList ilMain 
      Left            =   2415
      Top             =   735
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483643
      ImageWidth      =   16
      ImageHeight     =   16
      MaskColor       =   16711935
      _Version        =   393216
      BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
         NumListImages   =   7
         BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmToolSmartList.frx":08CA
            Key             =   "fldrClosed"
         EndProperty
         BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmToolSmartList.frx":0E64
            Key             =   "fldrOpen"
         EndProperty
         BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmToolSmartList.frx":13FE
            Key             =   "drive"
         EndProperty
         BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmToolSmartList.frx":1998
            Key             =   "explorer"
         EndProperty
         BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmToolSmartList.frx":1F32
            Key             =   "genericLarge"
         EndProperty
         BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmToolSmartList.frx":25CC
            Key             =   "genericMedium"
         EndProperty
         BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmToolSmartList.frx":28E6
            Key             =   "genericSmall"
         EndProperty
      EndProperty
   End
   Begin MSComctlLib.TreeView tvTreeView 
      Height          =   7095
      Left            =   0
      TabIndex        =   0
      Top             =   15
      Width           =   3120
      _ExtentX        =   5503
      _ExtentY        =   12515
      _Version        =   393217
      Indentation     =   529
      LabelEdit       =   1
      LineStyle       =   1
      Style           =   7
      ImageList       =   "ilMain"
      BorderStyle     =   1
      Appearance      =   1
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin MSComctlLib.ImageList ilSmall 
      Left            =   3255
      Top             =   720
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483643
      ImageWidth      =   16
      ImageHeight     =   16
      MaskColor       =   12632256
      _Version        =   393216
      BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
         NumListImages   =   2
         BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmToolSmartList.frx":2A40
            Key             =   "genericSmall"
         EndProperty
         BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmToolSmartList.frx":2B9A
            Key             =   "fldrClosed"
         EndProperty
      EndProperty
   End
   Begin MSComctlLib.ListView lvListView 
      Height          =   7095
      Left            =   3135
      TabIndex        =   1
      Top             =   15
      Width           =   9390
      _ExtentX        =   16563
      _ExtentY        =   12515
      View            =   3
      LabelEdit       =   1
      Sorted          =   -1  'True
      MultiSelect     =   -1  'True
      LabelWrap       =   -1  'True
      HideSelection   =   0   'False
      FullRowSelect   =   -1  'True
      GridLines       =   -1  'True
      _Version        =   393217
      ForeColor       =   -2147483640
      BackColor       =   -2147483643
      BorderStyle     =   1
      Appearance      =   1
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      NumItems        =   4
      BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         Key             =   "name"
         Text            =   "Trans. No."
         Object.Width           =   3528
      EndProperty
      BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         Alignment       =   1
         SubItemIndex    =   1
         Key             =   "size"
         Text            =   "Date"
         Object.Width           =   2540
      EndProperty
      BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   2
         Key             =   "type"
         Text            =   "Remarks"
         Object.Width           =   5292
      EndProperty
      BeginProperty ColumnHeader(4) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   3
         Key             =   "modified"
         Text            =   "Amount"
         Object.Width           =   2540
      EndProperty
   End
   Begin ITGControls.ITGTextBox txtModule 
      Height          =   285
      Left            =   8715
      TabIndex        =   2
      Top             =   7110
      Width           =   2250
      _ExtentX        =   3757
      _ExtentY        =   503
      SendKeysTab     =   -1  'True
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      AllCaps         =   -1  'True
      Label           =   "Records From"
      BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      LabelWidth      =   1250
      TextBoxWidth    =   940
   End
   Begin ITGControls.ITGTextBox ITGTextBox1 
      Height          =   285
      Left            =   11100
      TabIndex        =   3
      Top             =   7110
      Width           =   1395
      _ExtentX        =   2249
      _ExtentY        =   503
      SendKeysTab     =   -1  'True
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      AllCaps         =   -1  'True
      Label           =   "To"
      BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      LabelWidth      =   400
      TextBoxWidth    =   935
   End
End
Attribute VB_Name = "frmToolSmartList"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

'IT Group Inc. 2005.09.23

Option Explicit


Private connList As ADODB.Connection

'Object variables


'Other declaration
Public sBit As String

Private Sub Form_Activate()
    BitVisible ITGLedgerMain.tbrMain
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = True
    BitReload ITGLedgerMain, Me, ITGLedgerMain.tbrMain, sBit
    Set FrmName = Me
End Sub

Private Sub Form_Load()
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , , , , , , , , , , True
    BitVisible ITGLedgerMain.tbrMain, True
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = True

    Set FrmName = Me

    Me.Top = 0
    Me.Left = 2670
    
    LoadTree
    
End Sub

'Release your Object
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , , , , , , , True
    BitVisible ITGLedgerMain.tbrMain
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = False
 
    Me.Tag = "Close"
    Set frmToolSmartList = Nothing
    
    lCloseWindow = True
    
'    'oForm(Me.Tag).Mode = 1
'    'oForm(Me.Tag).Tag = Me.Tag
End Sub

'Close active window
Public Sub TBCloseWindow()
    Unload Me
End Sub

Sub LoadTree()
Dim nodRoot As Node

    Set nodRoot = tvTreeView.Nodes.Add(, , "Node1", "Customer")
    With nodRoot
        .Image = "fldrClosed"
        .Expanded = True
    End With
    AddTVNode nodRoot, "Node11", "All", "fldrClosed", "fldrOpen"
    AddTVNode nodRoot, "Node12", "Balance", "fldrClosed", "fldrOpen"
    AddTVNode nodRoot, "Node13", "Over Credit Limit", "fldrClosed", "fldrOpen"
    AddTVNode nodRoot, "Node14", "Past Due", "fldrClosed", "fldrOpen"
    
    Set nodRoot = tvTreeView.Nodes.Add(, , "Node2", "Products")
    With nodRoot
        .Image = "fldrClosed"
        .Expanded = True
    End With
    AddTVNode nodRoot, "Node21", "All", "fldrClosed", "fldrOpen"
    AddTVNode nodRoot, "Node22", "Balance", "fldrClosed", "fldrOpen"
    AddTVNode nodRoot, "Node23", "Below Reorder point", "fldrClosed", "fldrOpen"
    
    Set nodRoot = tvTreeView.Nodes.Add(, , "Node3", "Supplier")
    With nodRoot
        .Image = "fldrClosed"
        .Expanded = True
    End With
    AddTVNode nodRoot, "Node31", "All", "fldrClosed", "fldrOpen"
    AddTVNode nodRoot, "Node32", "Balance", "fldrClosed", "fldrOpen"
    AddTVNode nodRoot, "Node33", "Pending Deliveries", "fldrClosed", "fldrOpen"
    AddTVNode nodRoot, "Node34", "Inactive", "fldrClosed", "fldrOpen"
    
    Set nodRoot = tvTreeView.Nodes.Add(, , "Node4", "Receivables")
    With nodRoot
        .Image = "fldrClosed"
        .Expanded = True
    End With
    AddTVNode nodRoot, "Node41", "All", "fldrClosed", "fldrOpen"
    AddTVNode nodRoot, "Node42", "Returns", "fldrClosed", "fldrOpen"
    AddTVNode nodRoot, "Node43", "Past Due", "fldrClosed", "fldrOpen"
    AddTVNode nodRoot, "Node44", "Open Invoices", "fldrClosed", "fldrOpen"
    
    Set nodRoot = tvTreeView.Nodes.Add(, , "Node5", "Payables")
    With nodRoot
        .Image = "fldrClosed"
        .Expanded = True
    End With
    AddTVNode nodRoot, "Node51", "All", "fldrClosed", "fldrOpen"
    AddTVNode nodRoot, "Node52", "Open Invoices", "fldrClosed", "fldrOpen"
    AddTVNode nodRoot, "Node53", "Past Due", "fldrClosed", "fldrOpen"
    
Set nodRoot = tvTreeView.Nodes(1)

End Sub

Private Sub AddTVNode(ByRef ParentNode As Node, ByVal nodeKey As String, _
    ByVal nodeText As String, ByVal imgclose As String, ByVal imgopen As String)
    Dim newNode As Node
    Set newNode = tvTreeView.Nodes.Add(ParentNode, tvwChild, nodeKey, _
        nodeText, imgclose, imgopen)
End Sub

Private Sub lvListView_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
    lvListView.Sorted = True
    lvListView.SortKey = ColumnHeader.Index - 1
End Sub

Private Sub lvListView_DblClick()
Dim sModule As String
If lvListView.ListItems.Count = 0 Then Exit Sub

    Select Case Me.tvTreeView.SelectedItem.Key
        Case "Node11", "Node12", "Node13" 'Customer
            Set FrmName = frmMaintCustomer
            sModule = "Customer File"
        Case "Node21", "Node22", "Node31" 'Product File
            Set FrmName = frmMaintProduct
            sModule = "Product File"
    End Select
    If (sModule & "") <> "" Then
        With FrmName
            If .Mode = 1 Then
                MsgBox "Sytem detected that '" & Trim(sModule) & "' is in Add/Edit mode." & _
                        vbCr & "Please save/undo the current transaction.", vbCritical + vbOKOnly, "Comunion"
                FrmName.SetFocus
                Exit Sub
            Else
                .Show
                .ZOrder
                .ShowForm Trim(lvListView.SelectedItem)
            End If
        End With
    End If

End Sub

Private Sub tvTreeView_DblClick()
On Error GoTo ErrHandler
    Select Case tvTreeView.SelectedItem.Key
    Case "Node11"
        Customer_All
    Case "Node12"
        Customer_Balance
    Case "Node13"
        Customer_Credit
    Case "Node21"
        Product_All
    Case "Node22"
        Product_Balance
    Case "Node23"
        Product_Reorder
    Case "Node31"
        Supplier_All
    Case Else
        MsgBox "Hello garci?", vbInformation
    End Select
ErrHandler:
    If err.Number = 384 Then
        MsgBox "Form already open!", vbOKOnly, "ComUnion System"
        Exit Sub
    End If
End Sub


Sub Customer_All()
Dim rsGet As New Recordset
    lvListView.ColumnHeaders.Clear
    Set itmX = lvListView.ColumnHeaders.Add(, , "Code")
    Set itmX = lvListView.ColumnHeaders.Add(, , "Customer Name")
    Set itmX = lvListView.ColumnHeaders.Add(, , "Address")
    Set itmX = lvListView.ColumnHeaders.Add(, , "Phone")
    lvListView.ColumnHeaders(1).Width = "1000"
    lvListView.ColumnHeaders(2).Width = "2800"
    lvListView.ColumnHeaders(3).Width = "4000"
    lvListView.ColumnHeaders(4).Width = "1200"
    lvListView.ListItems.Clear
    sSQL = "Select cCode, cName, cAddress, cTel1 from CLIENT_CUSTOMER " & _
            " WHERE cCompanyID = '" & COID & "'"
    rsGet.Open sSQL, cn, adOpenKeyset, adLockReadOnly
    If rsGet.RecordCount <> 0 Then
        While Not rsGet.EOF
            Set itmX = lvListView.ListItems.Add(, , rsGet!cCode)
            itmX.SubItems(1) = rsGet!cName
            itmX.SubItems(2) = rsGet!cAddress & ""
            itmX.SubItems(3) = rsGet!cTel1 & ""
            rsGet.MoveNext
        Wend
    End If
    rsGet.Close
    Set rsGet = Nothing
End Sub

Sub Customer_Balance()
Dim cmdBalance As ADODB.Command
Dim rsGet As New Recordset

    lvListView.ColumnHeaders.Clear
    Set itmX = lvListView.ColumnHeaders.Add(, , "Code")
    Set itmX = lvListView.ColumnHeaders.Add(, , "Customer Name")
    Set itmX = lvListView.ColumnHeaders.Add(, , "Balance")
    lvListView.ColumnHeaders(1).Width = "1000"
    lvListView.ColumnHeaders(2).Width = "2800"
    lvListView.ColumnHeaders(3).Width = "1200"
    lvListView.ColumnHeaders(3).Alignment = lvwColumnRight
    lvListView.ListItems.Clear

    Set cmdBalance = New ADODB.Command
    With cmdBalance
        .ActiveConnection = cn
        .CommandTimeout = 1000
        .CommandText = "USP_CustomerBalance"
        .CommandType = adCmdStoredProc
        .Parameters("@cCompanyID") = COID
    End With
    Set rsGet = cmdBalance.Execute
    If rsGet.RecordCount <> 0 Then
        While Not rsGet.EOF
            Set itmX = lvListView.ListItems.Add(, , rsGet!cCode)
            itmX.SubItems(1) = rsGet!cName
            itmX.SubItems(2) = Format(rsGet!nBalance, "###,###,##0.#0")
            rsGet.MoveNext
        Wend
    End If
    rsGet.Close
    Set rsGet = Nothing

    Set cmdBalance = Nothing

End Sub

Sub Customer_Credit()
Dim cmdBalance As ADODB.Command
Dim rsGet As New Recordset

    lvListView.ColumnHeaders.Clear
    Set itmX = lvListView.ColumnHeaders.Add(, , "Code")
    Set itmX = lvListView.ColumnHeaders.Add(, , "Customer Name")
    Set itmX = lvListView.ColumnHeaders.Add(, , "Credit Limit")
    Set itmX = lvListView.ColumnHeaders.Add(, , "A/R")
    Set itmX = lvListView.ColumnHeaders.Add(, , "Balance")
    lvListView.ColumnHeaders(1).Width = "1000"
    lvListView.ColumnHeaders(2).Width = "2800"
    lvListView.ColumnHeaders(3).Width = "1200"
    lvListView.ColumnHeaders(4).Width = "1200"
    lvListView.ColumnHeaders(5).Width = "1200"
    lvListView.ColumnHeaders(3).Alignment = lvwColumnRight
    lvListView.ColumnHeaders(4).Alignment = lvwColumnRight
    lvListView.ColumnHeaders(5).Alignment = lvwColumnRight
    lvListView.ListItems.Clear

    Set cmdBalance = New ADODB.Command
    With cmdBalance
        .ActiveConnection = cn
        .CommandTimeout = 1000
        .CommandText = "USP_CustomerBalance"
        .CommandType = adCmdStoredProc
        .Parameters("@cCompanyID") = COID
    End With
    Set rsGet = cmdBalance.Execute
    If rsGet.RecordCount <> 0 Then
        While Not rsGet.EOF
            Set itmX = lvListView.ListItems.Add(, , rsGet!cCode)
            itmX.SubItems(1) = rsGet!cName
            itmX.SubItems(2) = Format(rsGet!nLimit, "###,###,##0.#0")
            itmX.SubItems(3) = Format(rsGet!nBalance, "###,###,##0.#0")
            itmX.SubItems(4) = Format(rsGet!nLimit - rsGet!nBalance, "###,###,##0.#0")
            rsGet.MoveNext
        Wend
    End If
    rsGet.Close
    Set rsGet = Nothing

    Set cmdBalance = Nothing

End Sub


Sub Product_All()
Dim rsGet As New Recordset
    lvListView.ColumnHeaders.Clear
    Set itmX = lvListView.ColumnHeaders.Add(, , "Item Code")
    Set itmX = lvListView.ColumnHeaders.Add(, , "Item Description")
    Set itmX = lvListView.ColumnHeaders.Add(, , "Type")
    Set itmX = lvListView.ColumnHeaders.Add(, , "Unit")
    Set itmX = lvListView.ColumnHeaders.Add(, , "Price")
    lvListView.ColumnHeaders(1).Width = "1200"
    lvListView.ColumnHeaders(2).Width = "3000"
    lvListView.ColumnHeaders(3).Width = "1200"
    lvListView.ColumnHeaders(4).Width = "1200"
    lvListView.ColumnHeaders(5).Width = "1200"
    lvListView.ColumnHeaders(5).Alignment = lvwColumnRight
    lvListView.ListItems.Clear
    sSQL = "Select cItemNo, cDesc, cType, cUnit, nSRPrice from ITEM WHERE cCompanyID = '" & COID & "'"
    rsGet.Open sSQL, cn, adOpenKeyset, adLockReadOnly
    If rsGet.RecordCount <> 0 Then
        While Not rsGet.EOF
            Set itmX = lvListView.ListItems.Add(, , rsGet!cItemNo)
            itmX.SubItems(1) = rsGet!cDesc & ""
            itmX.SubItems(2) = rsGet!cType & ""
            itmX.SubItems(3) = rsGet!cUnit & ""
            itmX.SubItems(4) = Format(rsGet!nSRPrice, "###,###,##0.#0")
            rsGet.MoveNext
        Wend
    End If
    rsGet.Close
    Set rsGet = Nothing
End Sub

Sub Product_Balance()
Dim cmdBalance As ADODB.Command
Dim rsGet As New Recordset

    lvListView.ColumnHeaders.Clear
    Set itmX = lvListView.ColumnHeaders.Add(, , "ItemNo")
    Set itmX = lvListView.ColumnHeaders.Add(, , "Product Desc")
    Set itmX = lvListView.ColumnHeaders.Add(, , "Unit")
    Set itmX = lvListView.ColumnHeaders.Add(, , "Type")
    Set itmX = lvListView.ColumnHeaders.Add(, , "Balance")
    lvListView.ColumnHeaders(1).Width = "1200"
    lvListView.ColumnHeaders(2).Width = "3000"
    lvListView.ColumnHeaders(3).Width = "1200"
    lvListView.ColumnHeaders(4).Width = "1200"
    lvListView.ColumnHeaders(5).Width = "1200"
    lvListView.ColumnHeaders(5).Alignment = lvwColumnRight
    lvListView.ListItems.Clear

    Set cmdBalance = New ADODB.Command
    With cmdBalance
        .ActiveConnection = cn
        .CommandTimeout = 1000
        .CommandText = "rsp_Listing_Product"
        .CommandType = adCmdStoredProc
        .Parameters(1) = ""
        .Parameters(2) = ""
        .Parameters(3) = ""
        .Parameters(4) = ""
        .Parameters(5) = ""
        .Parameters(6) = ""
        .Parameters(7) = ""
        .Parameters(8) = ""
        .Parameters(9) = ""
        .Parameters(10) = ""
        .Parameters(11) = COID
    End With
    Set rsGet = cmdBalance.Execute
    If rsGet.RecordCount <> 0 Then
        While Not rsGet.EOF
            Set itmX = lvListView.ListItems.Add(, , rsGet!cItemNo)
            itmX.SubItems(1) = rsGet!cDesc
            itmX.SubItems(2) = rsGet!cUnit
            itmX.SubItems(3) = rsGet!cType
            itmX.SubItems(4) = Format(rsGet!nBalance, "###,###,##0.#0")
            rsGet.MoveNext
        Wend
    End If
    rsGet.Close
    Set rsGet = Nothing

    Set cmdBalance = Nothing

End Sub

Sub Product_Reorder()
Dim rsGet As New Recordset
    lvListView.ColumnHeaders.Clear
    Set itmX = lvListView.ColumnHeaders.Add(, , "Item Code")
    Set itmX = lvListView.ColumnHeaders.Add(, , "Item Description")
    Set itmX = lvListView.ColumnHeaders.Add(, , "Unit")
    Set itmX = lvListView.ColumnHeaders.Add(, , "Reorder Pt")
    Set itmX = lvListView.ColumnHeaders.Add(, , "Balance")
    lvListView.ColumnHeaders(1).Width = "1200"
    lvListView.ColumnHeaders(2).Width = "3000"
    lvListView.ColumnHeaders(3).Width = "1200"
    lvListView.ColumnHeaders(4).Width = "1200"
    lvListView.ColumnHeaders(5).Width = "1200"
    lvListView.ColumnHeaders(5).Alignment = lvwColumnRight
    lvListView.ListItems.Clear
    sSQL = "select b.cItemNo, b.cDesc, b.cUnit, b.nReOrderPt, " & _
    "a.nInitial+a.nIncoming-a.nOutgoing+a.nRetSales-a.nRetPur-a.nIssues+ " & _
    "a.nBack-a.nProdOut+a.nProdIn+a.nAdjustment-a.nSampleDemo as nBalance " & _
    "from v_Productbalanceinquiry_module a " & _
    "inner join item b on a.cItemNo=b.cItemNo and a.cCompanyID=b.cCompanyID " & _
    "where a.cCompanyID='405-00'"
    rsGet.Open sSQL, cn, adOpenKeyset, adLockReadOnly
    If rsGet.RecordCount <> 0 Then
        While Not rsGet.EOF
            Set itmX = lvListView.ListItems.Add(, , rsGet!cItemNo)
            itmX.SubItems(1) = rsGet!cDesc & ""
            itmX.SubItems(2) = rsGet!cUnit & ""
            itmX.SubItems(3) = Format(rsGet!nReorderPt, "###,###,##0.#0")
            itmX.SubItems(4) = Format(rsGet!nBalance, "###,###,##0.#0")
            rsGet.MoveNext
        Wend
    End If
    rsGet.Close
    Set rsGet = Nothing
End Sub

Sub Supplier_All()
Dim rsGet As New Recordset
    lvListView.ColumnHeaders.Clear
    Set itmX = lvListView.ColumnHeaders.Add(, , "Code")
    Set itmX = lvListView.ColumnHeaders.Add(, , "Supplier Name")
    Set itmX = lvListView.ColumnHeaders.Add(, , "Address")
    Set itmX = lvListView.ColumnHeaders.Add(, , "Phone")
    lvListView.ColumnHeaders(1).Width = "1000"
    lvListView.ColumnHeaders(2).Width = "2800"
    lvListView.ColumnHeaders(3).Width = "4000"
    lvListView.ColumnHeaders(4).Width = "1200"
    lvListView.ListItems.Clear
    sSQL = "Select cCode, cName, cAddress, cTel from CLIENT_SUPPLIER " & _
            " WHERE cCompanyID = '" & COID & "'"
    rsGet.Open sSQL, cn, adOpenKeyset, adLockReadOnly
    If rsGet.RecordCount <> 0 Then
        While Not rsGet.EOF
            Set itmX = lvListView.ListItems.Add(, , rsGet!cCode)
            itmX.SubItems(1) = rsGet!cName
            itmX.SubItems(2) = rsGet!cAddress & ""
            itmX.SubItems(3) = rsGet!cTel & ""
            rsGet.MoveNext
        Wend
    End If
    rsGet.Close
    Set rsGet = Nothing
End Sub


